from pydantic import BaseModel
from typing import List, Optional
from datetime import datetime
from app.models.post import PostType, Campus

class PostBase(BaseModel):
    name: str
    campus: List[Campus]
    type: PostType
    poster: Optional[str] = None

class ActivityCreate(PostBase):
    activity_time: datetime
    submission_deadline: datetime
    content: str
    count_limit: Optional[int] = 0

class ActivityUpdate(ActivityCreate):
    pass

class Activity(ActivityCreate):
    id: int
    publisher_id: int
    current_count: int
    
    class Config:
        from_attributes = True

class AnnouncementCreate(PostBase):
    content_url: str

class AnnouncementUpdate(AnnouncementCreate):
    pass

class Announcement(PostBase):
    id: int
    published_time: datetime
    publisher_id: int
    content: str
    
    class Config:
        from_attributes = True

class PostList(BaseModel):
    total_page: int
    current_page: int
    has_next: bool
    data: List[Activity] | List[Announcement] 